<?php

/**
 * 筛选属性
 */

namespace app\site\api;

class FilterApi extends \dux\kernel\Api {

    public function getHtml() {
        $classId = request('get', 'class_id', 0, 'intval');
        $app = request('get', 'app', '', 'html_clear');
        $type = request('get', 'type', 0, 'intval');
        $contentId = request('get', 'content_id', 0, 'intval');
        if(empty($classId)) {
            $this->error('栏目未指定！');
        }
        if(empty($app)) {
            $this->error('应用未指定！');
        }
        $list = target($app.'/'.$app.'Class')->loadCrumbList($classId);
        $filterId = [];
        foreach ($list as $vo) {
            if($vo['filter_id']) {
                $filterId = $vo['filter_id'];
                break;
            }
        }
        $filterHtml = target('site/SiteFilter')->getHtml($filterId, $contentId, $type);
        $this->success($filterHtml);
    }

}